<?php $this->layout='main'; ?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/admin/common-script.js"></script>
<script type="text/javascript">

addHomeEvent();

/*
* param: the tab link user clicked
* focus on the profile tab
* display the content under the profile tab
*/
function displayProfile(element)
{
	activateTab(element, 'sp');
	var subHeadingElement=document.getElementById('sub-heading');
	subHeadingElement.firstChild.src = "<?php echo Yii::app()->request->baseUrl; ?>/images/my-admin.gif";
	var adminCharacter=document.getElementById('admin-character');
	adminCharacter.style.display="block";
	var profileElement=document.getElementById('profile-area');
	profileElement.style.display="block";
	var orgElement=document.getElementById('organization-area');
	orgElement.style.display="none";
	var paymentElement=document.getElementById('payment-area');
	paymentElement.style.display="none";
	var racksElement=document.getElementById('racks-area');
	racksElement.style.display="none";
	var otherusersElement=document.getElementById('otherusers-area');
	otherusersElement.style.display="none";

	$('#msg-header').html('');
	$('#msg-header').hide();
}

/*
* param: the tab link user clicked
* focus on the organization tab
* display the content under the organization tab
*/
function displayOrganization(element)
{
	activateTab(element, 'sp');
	var subHeadingElement=document.getElementById('sub-heading');
	subHeadingElement.firstChild.src = "<?php echo Yii::app()->request->baseUrl; ?>/images/my-admin.gif";
	var adminCharacter=document.getElementById('admin-character');
	adminCharacter.style.display="none";
	var profileElement=document.getElementById('profile-area');
	profileElement.style.display="none";
	var orgElement=document.getElementById('organization-area');
	orgElement.style.display="block";
	var paymentElement=document.getElementById('payment-area');
	paymentElement.style.display="none";
	var racksElement=document.getElementById('racks-area');
	racksElement.style.display="none";
	var otherusersElement=document.getElementById('otherusers-area');
	otherusersElement.style.display="none";

	$('#msg-header').html('');
	$('#msg-header').hide();
}

/*
* param: the tab link user clicked
* focus on the payment tab
* display the content under the payment tab
*/
function displayPayment(element)
{
	activateTab(element, 'sp');
	var subHeadingElement=document.getElementById('sub-heading');
	subHeadingElement.firstChild.src = "<?php echo Yii::app()->request->baseUrl; ?>/images/payment-setup.gif";
	var adminCharacter=document.getElementById('admin-character');
	adminCharacter.style.display="none";
	var profileElement=document.getElementById('profile-area');
	profileElement.style.display="none";
	var orgElement=document.getElementById('organization-area');
	orgElement.style.display="none";
	var paymentElement=document.getElementById('payment-area');
	paymentElement.style.display="block";
	var racksElement=document.getElementById('racks-area');
	racksElement.style.display="none";
	var otherusersElement=document.getElementById('otherusers-area');
	otherusersElement.style.display="none";

	$('#msg-header').html('');
	$('#msg-header').hide();
}

/*
* param: the tab link user clicked
* focus on the rack tab
* display the content under the rack tab
*/
function displayRacks(element)
{
	activateTab(element, 'sp');
	var subHeadingElement=document.getElementById('sub-heading');
	subHeadingElement.firstChild.src = "<?php echo Yii::app()->request->baseUrl; ?>/images/my-geography.gif";
	var adminCharacter=document.getElementById('admin-character');
	adminCharacter.style.display="none";
	var profileElement=document.getElementById('profile-area');
	profileElement.style.display="none";
	var orgElement=document.getElementById('organization-area');
	orgElement.style.display="none";
	var paymentElement=document.getElementById('payment-area');
	paymentElement.style.display="none";
	var racksElement=document.getElementById('racks-area');
	racksElement.style.display="block";
	var otherusersElement=document.getElementById('otherusers-area');
	otherusersElement.style.display="none";

	$('#msg-header').html('');
	$('#msg-header').hide();
}

/*
* param: the tab link user clicked
* focus on the otherusers tab
* display the content under the otherusers tab
*/
function displayOtherUsers(element)
{
	activateTab(element, 'sp');
	var subHeadingElement=document.getElementById('sub-heading');
	subHeadingElement.firstChild.src = "<?php echo Yii::app()->request->baseUrl; ?>/images/my-admin.gif";
	var adminCharacter=document.getElementById('admin-character');
	adminCharacter.style.display="none";
	var profileElement=document.getElementById('profile-area');
	profileElement.style.display="none";
	var orgElement=document.getElementById('organization-area');
	orgElement.style.display="none";
	var paymentElement=document.getElementById('payment-area');
	paymentElement.style.display="none";
	var racksElement=document.getElementById('racks-area');
	racksElement.style.display="none";
	var otherusersElement=document.getElementById('otherusers-area');
	otherusersElement.style.display="block";

	$('#msg-header').html('');
	$('#msg-header').hide();
}

</script>

<?php $row=$model->getInfoByID(Yii::app()->user->userID); ?>

<div id="contents-admin">
<div id="sub-heading"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/my-admin.gif" alt="" /></div>

<div id="admin-content-area">

<div id="admin-menu2">
<div class="navi3">
    <ul>
        <li name='tabs' class="sp1 sp-active1"><?php echo CHtml::link('Profile','#', array(
									'title' => 'Profile',
									'onclick' => 'displayProfile(this)',
											)) ?></li>
        <li name='tabs' class="sp2"><?php echo CHtml::link('Payment','#', array(
									'title' => 'Payment',
									'onclick' => 'displayPayment(this)',
											)) ?></li>
        <li name='tabs' class="sp3"><?php echo CHtml::link('Racks','#', array(
									'title' => 'Racks',
									'onclick' => 'displayRacks(this)',
											)) ?></li>
		<?php if(Yii::app()->user->roleType==UserRole::$ADMIN) { ?>
		<li name='tabs' class="sp4"><?php echo CHtml::link('Organization','#', array(
									'title' => 'Organization',
									'onclick' => 'displayOrganization(this)',
											)) ?></li>
		<li name='tabs' class="sp5"><?php echo CHtml::link('Other users', '#', array(
									'title' => 'Other users',
									'onclick' => 'displayOtherUsers(this)',
											)); ?></li>
		<?php } ?>
    </ul>
</div>
</div><!-- End Admin Menu -->

<div id="admin-character"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/admin-character.jpg" alt="" /></div>

<div id="admin-textarea">
	<div id="profile-area" style="display:block">
		<?php $this->renderPartial('profile', array('model' => $model, 'row'=>$row)); ?>
  	</div>
  	<div id="payment-area" style="display:none">
  		<?php include_once('payment.php'); ?>
  	</div>
  	<div id="racks-area" style="display:none">
  		<?php include_once('rack.php'); ?>
  	</div>
  	<div id="organization-area" style="display:none">
		<?php 
			if(Yii::app()->user->roleType==UserRole::$ADMIN){
				include_once('organization.php');
			} 
		?>
  	</div>
  	<div id="otherusers-area" style="display:none">
		<?php 
			if(Yii::app()->user->roleType==UserRole::$ADMIN){
				$this->renderPartial('otherusers', array('usersDataProvider'=>$usersDataProvider));
			} 
		?>
  	</div>
</div><!-- End Admin Text Area -->

<!--
<div class="submit-button"><input type="image" src="<?php echo Yii::app()->request->baseUrl; ?>/images/submit.jpg" /></div>
-->
</div><!-- End Admin Contents Area -->

</div><!-- End Contents Admin -->
